@using BlazorApp.Pages.Common.Html.HTable
@inherits FeedbackComponent<double, double>
<HTable Class="miniTable">


    <HTr>
        <HTd>@L["Current"] </HTd>
        <HTd>
            <Text>@_replicas</Text>
        </HTd>
        <HTd>

        </HTd>
    </HTr>
    <HTr>
        <HTd>@L["Desired"]</HTd>
        <HTd>
            <Space Size="@("20")">

                <SpaceItem>
                    <div style="float: left">@_value</div>
                </SpaceItem>
                <SpaceItem>
                    <Slider Style="float:left;width: 150px" Min="1" Max="100" Step="1" @bind-Value="@_value"/>
                </SpaceItem>
                <SpaceItem>
                    <AntDesign.InputNumber Min="1" Max="100" @bind-Value="@_value" TValue="double"/>
                </SpaceItem>
            </Space>
        </HTd>
    </HTr>
    @if (_value >= 90)
    {
        <HTr>
            <HTd ColSpan="3">
                <Alert Message=@L["High number of replicas may cause cluster performance issues"] Type="@AlertType.Warning"/>
            </HTd>
        </HTr>
    }
</HTable>


@code{

    [Inject] public IStringLocalizer L { get; set; }

    private double _replicas;

    private double _value;

    protected override void OnInitialized()
    {
        _replicas = this.Options;
        _value = _replicas;
        base.OnInitialized();
    }


    public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
    {
        if (FeedbackRef is ConfirmRef confirmRef)
        {
            confirmRef.Config.OkButtonProps.Loading = true;
            await confirmRef.UpdateConfigAsync();
        }
        else if (FeedbackRef is ModalRef modalRef)
        {
            modalRef.Config.ConfirmLoading = true;
            await modalRef.UpdateConfigAsync();
        }

        await base.OkCancelRefWithResult!.OnOk(_value);

        await base.OnFeedbackOkAsync(args);
    }

}
